<template>
	<view>
		<view class="kind_contain">
			<view class="kind_item" v-for="(item, index) in kindList" :key="index">
				<navigator :url="kindUrl(item)">
					<image class="item_icon" :src="item.icon" mode="aspectFill"></image>
					<text class="item_name">{{item.name}}</text>
				</navigator>
			</view>
		</view>
	</view>
</template>

<script>
	import request from '../../api/request.js';
	export default {
		data() {
			return {
				kindList: []
			};
		},

		methods: {
			// 请求分类数据
			async requestKindList() {
				let res = await request({
					url: '/home/categorys/1308336521604599809'
				})
				this.kindList = res.data.data.category.children;
			},
		},
		onLoad() {
			this.requestKindList()
		},
		computed: {
			kindUrl() {
				return function(item) {
					return './kindPage/kindPage?categoryId='+ item.id
				}
			}
		}


	}
</script>

<style lang="scss" scoped>
	page {
		background-color: $uni-bg-color;
	}

	.kind_contain {
		display: flex;
		flex-wrap: wrap;
		width: 95%;
		height: calc(100vh - 100rpx);
		margin: auto;
		

		.kind_item {
			position: relative;
			.item_name {
				position: absolute;
				left: 46rpx;
				top: 148rpx;
				font-size: 48rpx;
			}
			&:nth-child(1), {
				color: #fff
			}
			&:nth-child(1),
			&:nth-child(2) {
				width: 670rpx;
				margin: auto;
				text-align: center;
				
					border-radius: 50rpx;
				.item_icon {
					height: 300rpx;
					width: 100%;

				}

			}


			,
			&:nth-child(3),
			&:nth-child(4) {
				width: 312rpx;
				margin: auto;
				text-align: center;
				
				.item_icon {
					height: 440rpx;
					width: 312rpx;
					border-radius: 30rpx;

				}
			}
		}
	}
</style>
